#!/usr/bin/node

const Koa = require('koa');
const task = require('./lib/task.js');
const app = new Koa();

app.use(async (ctx, next) => {    //M-logger
  //console.log(`${ctx.method} ${ctx.url}`);
  const start = new Date();
  await next();
  const end = new Date();
  console.log(ctx.method);
  console.log(end-start);
});

app.use(async (ctx, next) => {     //M-hello
  ctx.body = 'hello koa! tesk cost: ' + await task() + 'ms..';

});

app.listen(8080);
console.log('hello world');


